package cn.itcast.bos.activemq;

import javax.jms.MapMessage;
import javax.jms.Message;
import javax.jms.MessageListener;

import org.springframework.stereotype.Component;

import com.aliyuncs.dysmsapi.model.v20170525.SendSmsResponse;

import cn.itcast.bos.utils.SmsDemoUtils2;

@Component("queueConsumer1")
public class CourierSmsConsumer implements MessageListener {

	@Override
	public void onMessage(Message message) {
		MapMessage mapMessage = (MapMessage) message;
		try {
			String telephone = mapMessage.getString("telephone");
			String num = mapMessage.getString("num"); // 验证码
			String sendAddres = mapMessage.getString("sendAddres"); // 寄件人地址
			String sendName = mapMessage.getString("sendName"); // 寄件人
			String sendMobile = mapMessage.getString("sendMobile"); // 寄件人电话
			String sendMobileMsg = mapMessage.getString("sendMobileMsg"); // 快递员稍话
			// 内容可以新建一个模板，然后发送新的短信内容即可。
			SendSmsResponse sendSmsResponse = SmsDemoUtils2.sendSms(telephone, num, sendAddres, sendName, sendMobile,
					sendMobileMsg);

		} catch (Exception e) {
			e.printStackTrace();
		}
	}

}
